<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增界面</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
    <script type="text/javascript" src="bootstrap/js/jquery.js"></script>
    <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <form>
        <div class="form-group">
            <label for="exampleInputEmail1">用户名</label>
            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="请输入用户名">
        </div>
        <div class="form-group">
            <label for="exampleInputPassword1">密码</label>
            <input type="password" class="form-control" id="exampleInputPassword1" placeholder="请输入密码">
        </div>
        <div class="form-group">
            <label for="exampleInputPassword2">用户状态</label>
            <input type="password" class="form-control" id="exampleInputPassword2" placeholder="请输入用户状态">
        </div>

        <input onclick='location.href=("crud.html")' id="sub"  class="btn btn-success form-control" type="button" value="新增">
    </form>

</div>

</body>
</html>
<script type="text/javascript">
    $("#sub").click(function () {
        var username = $("#exampleInputEmail1").val();
        var password = $("#exampleInputPassword1").val();
        var status = $("#exampleInputPassword2").val();
        if (username.length == 0){
            alert("用户名不可为空")
        }
        if (password.length == 0){
            alert("密码不可为空")
        }
        if(status.length == 0){
            alert("用户状态不可为空")
        }

        var data = {
            "username":username,
            "password":password,
            "status":status
        }
        
        var userJson = JSON.stringify(data)
        
        $.post({
            url:'Crud/save',
            data:userJson,
            contentType:'application/json',
            success:function (data) {
            }
        });
        
    })
</script>